<template>
  <div>
    <div class="profile flex" style="align-items: center">
      <div class="flex profile-avatar">
        <div class="text-center">
          <UserAvatar :img="userInfo?.avatar" />
        </div>
        <div class="profile-username"> {{ userInfo?.username }}</div>
      </div>
      <div>
        <div class="profile-item">
          <div>用户姓名</div>
          <div>{{ userInfo?.nickname }}</div>
        </div>
        <div class="profile-item">
          <div>手机号码</div>
          <div>{{ userInfo?.mobile }}</div>
        </div>
      </div>
      <div style="margin-left: 112px">
        <div class="profile-item">
          <div>所属职能</div>
          <div>{{ userInfo?.org }}</div>
        </div>
        <div class="profile-item">
          <div>创建日期</div>
          <div>{{ formatDate(userInfo?.createTime) }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { formatDate } from '@/utils/formatTime'
import UserAvatar from './UserAvatar.vue'

import { getUserProfile, ProfileVO } from '@/api/system/user/profile'

defineOptions({ name: 'ProfileUser' })

const { t } = useI18n()
const userInfo = ref({} as ProfileVO)
const getUserInfo = async () => {
  const users = await getUserProfile()
  userInfo.value = users
}
onMounted(async () => {
  await getUserInfo()
})
</script>

<style scoped lang="scss">
.profile {
  &-item {
    display: flex;
    margin: 24px 0;
    margin-left: 20px;
    font-size: 14px;
    font-weight: 400;

    div:first-child {
      color: #999;
    }

    div:last-child {
      margin-left: 24px;
      color: #0d0d0d;
    }
  }

  &-avatar {
    align-items: center;

    .profile-username {
      min-width: 220px;
      margin-left: 24px;
      font-size: 20px;
      font-weight: 500;
      color: #0d0d0d;
    }
  }
}

.text-center {
  position: relative;
  height: 120px;
  text-align: center;
}

.list-group-striped > .list-group-item {
  padding-right: 0;
  padding-left: 0;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
}

.list-group {
  padding-left: 0;
  list-style: none;
}

.list-group-item {
  padding: 11px 0;
  margin-bottom: -1px;
  font-size: 13px;
  border-top: 1px solid #e7eaec;
  border-bottom: 1px solid #e7eaec;
}

.pull-right {
  float: right !important;
}
</style>
